﻿using System;
using System.Collections.Generic;
using Rodunu.Movies.Services.Models.Netflix.Enums;

namespace Rodunu.Movies.Services.NetFlix.DataProvider
{
    public static class EnumHelper
    {
        private static Dictionary<Type, Dictionary<string, object>> _mappings =
            new Dictionary<Type, Dictionary<string, object>> {
                { typeof(Format), new Dictionary<string,object> {
                    { "DVD", Format.DVD },
                    { "HD DVD", Format.HDDVD },
                    { "instant", Format.Instant },
                    { "Blu-ray", Format.BluRay }
                }},

                { typeof(Availability), new Dictionary<string,object> {
                    { "available now", Availability.Now },
                    { "awaiting release", Availability.AwaitingRelease },
                    { "saved", Availability.Saved }
                }},
                
                { typeof(RentalStates), new Dictionary<string,object> {
                    { "returned", RentalStates.Returned },
                    { "shipped", RentalStates.Shipped },
                    { "watched", RentalStates.Watched }
                }},
                
                { typeof(TitleStatesAction), new Dictionary<string,object> {
                    { "add", TitleStatesAction.Add },
                    { "unavailable" , TitleStatesAction.Unavailable },
                    { "play", TitleStatesAction.Play }
                }},

                { typeof(Rating), new Dictionary<string,object> {
                    { "UR", Rating.UR },
                    { "R", Rating.R },
                    { "PG", Rating.PG },
                    { "G", Rating.G },
                    { "NC-17", Rating.NC17 },
                    { "PG-13", Rating.PG13 },
                    { "TV-PG", Rating.TVPG },
                    { "TV-MA", Rating.TVMA },
                    { "NR", Rating.NR },
                    { "TV-14", Rating.TV14 }
                }}};
                

        public static object GetValue(Type enumType, string item)
        {
            if (_mappings[enumType].ContainsKey(item))
                return _mappings[enumType][item];
            return null;
        }
    }
}
